import bodyParser from 'body-parser'
import cookieParser from 'cookie-parser'
import session from 'express-session'

export default {
  head: {
    title: '雪顿云商',
    meta: [
      { charset: 'utf-8' },
      { hid: 'description', content: 'Auth Routes example' }
    ]
  },
  build: {
    postcss: [
      require('autoprefixer')({
        browsers: ['Android >= 4.0', 'iOS >= 7']
      }),
      require('postcss-pxtorem')({
        rootValue: 10,
        propList: ['*']
      })
    ],
  },
  css: [
    {src: '~assets/stylus/index.styl', lang: 'stylus'}
  ],
  /*
  ** Add server middleware
  ** Nuxt.js uses `connect` module as server
  ** So most of express middleware works with nuxt.js server middleware
  */
  plugins: [
    '~/plugin/vant',
    '~/plugin/ajax',
    '~/plugin/wxShare',
    { src: '~/plugin/vconsole', ssr: false },
    { src: '~/plugin/route', ssr: false },
  ],
  serverMiddleware: [
    // body-parser middleware
    bodyParser.json(),
    cookieParser(),
    // session middleware
    session({
      secret: 'super-secret-key',
      resave: false,
      saveUninitialized: false,
      cookie: { maxAge: 6000000000 }
    }),
    // Api middleware
    // We add /api/login & /api/logout routes
    '~/api',
    '~/api/dispatch.js'
  ],
  server: {
    host: '0.0.0.0',
    // port: 9010,
    port: 8081,
  },
  router: {
    middleware: ['ajax', 'auth']
  }
}
